package com.ci.model.impl;

import com.ci.dao.query.HDConfigQuery;
import java.io.Serializable;
import java.util.Date;
import javax.inject.Named;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * @author Lang Yu
 * @description 该模型为HDSerial，主要是为了按照不同的规则来生成所需要的主要编号而定制的
 * @date Aug 31, 2010 2:59:42 AM
 * @version 1.0
 */
@Entity
@Table(name = "CFG_SERIAL", uniqueConstraints = {
    @UniqueConstraint(columnNames = {
        // 不可重复的主键对应的名称
        "ID", "CLASSNAME"
    })
})
@NamedQueries({
    @NamedQuery(name = HDConfigQuery.SERIAL_Q_ALL_Key, query = HDConfigQuery.SERIAL_Q_ALL_VALUE)
})
@Named("HDSerialModel")
public class HDSerial implements Serializable {

    private static final long serialVersionUID = 5747716735571684584L;
    // 该表对应的Serial在数据库里面的Id号
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID", nullable = false)
    private int id = 1;
    // ClassName针对的模型的名称，作为了模型的标识
    @Column(name = "CLASSNAME", nullable = false)
    private String className;
    // 目前数字里面的最后一个数值
    @Column(name = "LASTNUMBER", nullable = false)
    private long lastNumber;
    // 重置的值
    @Column(name = "RESETPOINT")
    private long resetPoint;
    // 增加或者减小的幅度
    @Column(name = "BATCHSIZE")
    private int batchSize;
    // 若为true，该序列号需要减小，若为false，该序列号需要增加
    @Column(name = "ISDECREMENT")
    private boolean isDecrement;
    // 描述信息
    @Column(name = "DESCRIPTION")
    private String description;
    // 序列号的长度
    @Column(name = "WIDTH")
    private int width;
    // 序列号的前缀
    @Column(name = "SERIALPREFIX")
    private String serialPrefix;
    // 序列号的后缀
    @Column(name = "SERIALSUFFIX")
    private String serialSuffix;
    // 创建时间
    @Column(name = "CREATETIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    /**
     * @return the className
     */
    public String getClassName() {
        return className;
    }

    /**
     * @param className the className to set
     */
    public void setClassName(String className) {
        this.className = className;
    }

    /**
     * @return the lastNumber
     */
    public Long getLastNumber() {
        return lastNumber;
    }

    /**
     * @param lastNumber the lastNumber to set
     */
    public void setLastNumber(Long lastNumber) {
        this.setLastNumber((long) lastNumber);
    }

    /**
     * @return the resetPoint
     */
    public long getResetPoint() {
        return resetPoint;
    }

    /**
     * @param resetPoint the resetPoint to set
     */
    public void setResetPoint(long resetPoint) {
        this.resetPoint = resetPoint;
    }

    /**
     * @return the batchSize
     */
    public int getBatchSize() {
        return batchSize;
    }

    /**
     * @param batchSize the batchSize to set
     */
    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }

    /**
     * @return the isDecrement
     */
    public boolean isIsDecrement() {
        return isDecrement;
    }

    /**
     * @param isDecrement the isDecrement to set
     */
    public void setIsDecrement(boolean isDecrement) {
        this.isDecrement = isDecrement;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @param lastNumber the lastNumber to set
     */
    public void setLastNumber(long lastNumber) {
        this.lastNumber = lastNumber;
    }

    /**
     * @return the width
     */
    public int getWidth() {
        return width;
    }

    /**
     * @param width the width to set
     */
    public void setWidth(int width) {
        this.width = width;
    }

    /**
     * @return the serialPrefix
     */
    public String getSerialPrefix() {
        return serialPrefix;
    }

    /**
     * @param serialPrefix the serialPrefix to set
     */
    public void setSerialPrefix(String serialPrefix) {
        this.serialPrefix = serialPrefix;
    }

    /**
     * @return the serialSuffix
     */
    public String getSerialSuffix() {
        return serialSuffix;
    }

    /**
     * @param serialSuffix the serialSuffix to set
     */
    public void setSerialSuffix(String serialSuffix) {
        this.serialSuffix = serialSuffix;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
